Skip to content

Small code fixes to Placement Plugins#4213

Merged
epugh merged 3 commits intoapache:mainfrom
epugh:code_review_of_placement_plugins
Mar 17, 2026
Merged

Small code fixes to Placement Plugins#4213
epugh merged 3 commits intoapache:mainfrom
epugh:code_review_of_placement_plugins

Conversation

@epugh
Copy link
Copy Markdown
Contributor

@epugh epugh commented Mar 13, 2026

Reading through this code to learn about placement plugins I fixed some typos and small code clean ups.

}

// If there are not multiple spreadDomains, then there is nothing to spread across
// only spread across if there are multiple spreadDomains
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope this is a clearer comment...

@epugh epugh requested a review from HoustonPutman March 13, 2026 11:36
Copy link
Copy Markdown
Contributor

@HoustonPutman HoustonPutman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally approve, thanks for the cleanup!


List<WeightedNode> nodesForRequest =
weightedNodes.stream().filter(request::isTargetingNode).collect(Collectors.toList());
weightedNodes.stream().filter(request::isTargetingNode).toList();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if the read-only contract is different between these two options, but good to check. Same down below.

Copy link
Copy Markdown
Contributor Author

@epugh epugh Mar 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

humm, I'm hoping no differences because tests don't fail and IntelliJ recommended it! Let's see what copilot says!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude looked at it and explained about the mutability thing... It's interesting that nothing in the class speaks to mutablity which feels like a trap. I mean, do I really need to think about mutability? It's like asking me to think about memory management!!! What are we? C code?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes small cleanups and typo fixes in Solr placement plugin code, primarily improving readability and modernizing a couple of Java stream usages.

Changes:

  • Removes unused code in placement plugin tests and plugin internals.
  • Fixes minor Javadoc/comment typos in placement plugin classes.
  • Replaces collect(Collectors.toList()) with Stream.toList() and refactors instanceof chains to a switch pattern.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
solr/core/src/test/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactoryTest.java Removes an unused variable in a test.
solr/core/src/java/org/apache/solr/cluster/placement/plugins/RandomPlacementFactory.java Fixes a small Javadoc punctuation typo.
solr/core/src/java/org/apache/solr/cluster/placement/plugins/OrderedNodePlacementPlugin.java Uses toList(), refactors request-type handling to a switch, and adjusts comments.
solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementFactory.java Small comment rewording and simplifies a helper method signature.
solr/core/src/java/org/apache/solr/cluster/placement/plugins/AffinityPlacementConfig.java Javadoc tweaks; includes a newly introduced punctuation typo.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

epugh and others added 2 commits March 16, 2026 14:58
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@epugh
Copy link
Copy Markdown
Contributor Author

epugh commented Mar 17, 2026

Had to back out the switch as google-java-format is out of date and didn't like it.

@epugh epugh merged commit 8c64932 into apache:main Mar 17, 2026
4 of 5 checks passed
epugh added a commit that referenced this pull request Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants